#pragma once

#include <QLabel>
#include <QTabWidget>
#include <QTcpServer>
#include <QVBoxLayout>
#include <QWidget>

#include "../game/Player.h"
#include "tabs/AddressPanel.h"
#include "tabs/GamePanel.h"

enum class State {
    Offline,
    Waiting,
    Running
};

static const QString OFFLINE_TEXT = "<span>当前状态：</span><span style=\"color: red\">离线</span>";
static const QString WAITING_TEXT = "<span>当前状态：</span><span style=\"color: dodgerblue\">等待中</span>";
static const QString RUNNING_TEXT = "<span>当前状态：</span><span style=\"color: darkorange\">运行中</span>";

class MainWindow : public QWidget {
    Q_OBJECT
private:
    QLabel* title_label;
    QTabWidget* tabs;
    QVBoxLayout* widget_layout;

    AddressPanel* addressPanel;
    GamePanel* gamePanel;

    QLabel* state_label;
    State state;

    QTcpServer* server;
    QVector<Player*> players;

public:
    MainWindow();

    void setState(State state);

    void broadcast(const QString& msg);

public slots:
    void onLaunched();
    void onQuited();
    void onStarted();
    void onFinished();
    void onNewConnection();
};
